package com.yax.mickey.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yax.mickey.entity.User;
import org.apache.ibatis.annotations.*;

/**
* @author yax
* @description 针对表【user(用户信息表)】的数据库操作Mapper
* @createDate 2024-05-12 21:23:09
* @Entity com.yax.mickey.entity.User
*/

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("select * from user where username = #{username}")
    User getByUsername(String username);

    @Select("select * from `user` where username = #{username}")
    User getUserByUsername(String username);

    @Insert("insert into `user` (username, password) values (#{username}, #{password});")
    void register(@Param("username") String username,@Param("password") String password);

    @Insert("insert into `user` (user_id, username, password, phone_number, avatar, nickname) \n" +
            "values (#{userId}, #{username}, #{password}, #{phoneNumber}, #{avatar}, #{nickname});")
    Integer addUser(User user);

    @Update("update `user` set phone_number = #{phoneNumber}, avatar = #{avatar}, nickname = #{nickname} where user_id = #{userId}")
    void updateUser(User user);

}




